/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "hhdTypes.h"

namespace hhd
{
	/**
	* InputStream is a pure virtual class which all other InputStream style classes will
	* inherit from.
	*/

	class InputStream
	{
	public:
		/**
		* Method closes the underlying InputStream to further reading.
		*/
		virtual void close();

		/**
		* This method reads one byte from the input stream.  Returns a negative value if there was a problem reading.
		* @return the read byte
		*/
		virtual bool read(char8_t& out_char) = 0;
		
		/**
		* This method writes multiple bytes into a char array from the stream.  The basic implementation repeatedly calls
		* read() but can be overridden by child classes.  If we reach end of stream before writing in_length bytes, we 
		* return the number of bytes written.
		* @param in_out_buffer a character array to serve as a buffer for the InputStream
		* @param in_length the number of bytes to read
		* @return The number of bytes written to in_out_buffer
		*/
		virtual bool read(char8_t* in_out_buffer, size_t in_length);
		
		/**
		* This method should reset the InputStream to the initial position.  Parent implementation does nothing.
		*/
		virtual void reset();
		
		/**
		* Skips a number of bytes without returning results to the user.  Parent implementation repeatedly calls read(),
		* but children should override with a better implementation.
		* @param in_bytes The number of bytes to skip
		*/
		virtual void skip(size_t in_bytes);
	};
}
